package org.zachary.prosocialbehaviorservice.infrastructure.repository;

import org.springframework.stereotype.Repository;
import org.zachary.prosocialbehaviorservice.application.command.JoinExitActivityCommand;
import org.zachary.prosocialbehaviorservice.domain.aggregate_model.activity.ActivityItem;
import org.zachary.prosocialbehaviorservice.domain.aggregate_model.activity.ActivityToItem;
import org.zachary.prosocialbehaviorservice.domain.repository.ActivityToItemRepository;

import java.util.List;
import java.util.Optional;

@Repository
public class JpaActivityToItemRepository implements ActivityToItemRepository {
    private final SpringDataActivityToItemRepository jpaRepo;

    public JpaActivityToItemRepository(SpringDataActivityToItemRepository jpaRepo) {
        this.jpaRepo = jpaRepo;

    }

    @Override
    public List<ActivityToItem> findByActivityId(Integer activityId) {
        return jpaRepo.findByActivityId(activityId);
    }

    @Override
    public void save(ActivityToItem rel) {
        jpaRepo.save(rel);
    }

    @Override
    public void deleteById(Integer itemId) {
        jpaRepo.deleteByItemId(itemId);
    }

    @Override
    public Optional<Integer> findActivityIdByItemId(Integer id) {
        return jpaRepo.findActivityIdByItemId(id);
    }

    @Override
    public Optional<ActivityToItem> findByItemId(Integer itemId) {
        return jpaRepo.findByItemId(itemId);
    }


}
